Updating from v12 to v13 | 您所在的位置:网站首页 › Advanced Discordjs Custom embeds using attachments › Updating from v12 to v13 |
# Updating from v12 to v13# Before you start v13 requires Node 16.6 or higher to use, so make sure you're up to date. To check your Node version, use node -v in your terminal or command prompt, and if it's not high enough, update it! There are many resources online to help you with this step based on your host system. Once you've got Node up-to-date, you can install v13 by running the appropriate command in your terminal or command prompt. npm install discord.js # text-only npm install discord.js @discordjs/voice # voice support yarn add discord.js # text-only yarn add discord.js @discordjs/voice # voice support pnpm add discord.js # text-only pnpm add discord.js @discordjs/voice # voice supportYou can check your discord.js version with the list command. Should it still show v12.x, uninstall and re-install discord.js and make sure the entry in your package.json does not prevent a major version update. Please refer to the npm documentationopen in new window for this. # check version npm list discord.js # uninstall and re-install npm uninstall discord.js npm install discord.js # check version yarn list discord.js # uninstall and re-install yarn remove discord.js yarn add discord.js # check version pnpm list discord.js # uninstall and re-install pnpm remove discord.js pnpm add discord.js # API versiondiscord.js v13 makes the switch to Discord API v9! In addition to this, the new major version also includes a bunch of cool new features. # Slash commandsdiscord.js now has support for slash commands! Refer to the slash commands section of this guide to get started. In addition to the interactionCreate event covered in the above guide, this release also includes the new Client events applicationCommandCreate, applicationCommandDelete, and applicationCommandUpdate. # Message componentsdiscord.js now has support for message components! This introduces the MessageActionRow, MessageButton, and MessageSelectMenu classes, as well as associated interactions and collectors. Refer to the message components section of this guide to get started. # Threadsdiscord.js now has support for threads! Threads are a new type of sub-channel that can be used to help separate conversations into a more meaningful flow. This introduces the ThreadManager class, which can be found as TextChannel#threads, in addition to ThreadChannel, ThreadMemberManager, and ThreadMember. There are also five new events: threadCreate, threadUpdate, threadDelete, threadListSync, threadMemberUpdate, and threadMembersUpdate. Refer to the threads section of this guide to get started. # VoiceSupport for voice has been separated into its own module. You now need to install and use @discordjs/voiceopen in new window for interacting with the Discord Voice API. Refer to the voice section of this guide to get started. # Customizable Manager cachesA popular request that has finally been heard - the Client class now has a new option, makeCache. It accepts a CacheFactory. By combining this with the helper function Options.cacheWithLimits, users can define limits on each Manager's cache and let discord.js handle the rest. const client = new Client({ makeCache: Options.cacheWithLimits({ MessageManager: 200, // This is default PresenceManager: 0, // Add more class names here }), }); 1234567Additional flexibility can be gained by providing a function which returns a custom cache implementation. Keep in mind this should still maintain the Collection/Map-like interface for internal compatibility. const client = new Client({ makeCache: manager => { if (manager.name === 'MessageManager') return new LimitedCollection({ maxSize: 0 }); return new Collection(); }, }); 123456# Commonly used methods that changed# Sending messages, embeds, files, etc.With the introduction of Interactions and it becoming far common for users to want to send an embed with MessageOptions, methods that send messages now enforce a single param. This can be either a string, a MessagePayload, or that method's variant of MessageOptions. Additionally, all messages sent by bots now support up to 10 embeds. As a result, the embed option was removed and replaced with an embeds array, which must be in the options object. - channel.send(embed); + channel.send({ embeds: [embed, embed2] }); - channel.send('Hello!', { embed }); + channel.send({ content: 'Hello!', embeds: [embed, embed2] }); - interaction.reply('Hello!', { ephemeral: true }); + interaction.reply({ content: 'Hello!', ephemeral: true }); 12345678MessageEmbed#attachFiles has been removed; files should now be attached directly to the message instead of the embed. - const embed = new Discord.MessageEmbed().setTitle('Attachments').attachFiles(['./image1.png', './image2.jpg']); - channel.send(embed); + const embed = new Discord.MessageEmbed().setTitle('Attachments'); + channel.send({ embeds: [embed], files: ['./image1.png', './image2.jpg'] }); 1234The code and split options have also been removed. This functionality will now have to be handled manually, such as via the Formatters.codeBlock and Util.splitMessage helpers. # StringsMany methods in discord.js that were documented as accepting strings would also accept other types and resolve this into a string on your behalf. The results of this behavior were often undesirable, producing output such as [object Object]. discord.js now enforces and validates string input on all methods that expect it. Users will need to manually call toString() or utilize template literals for all string inputs as appropriate. The most common areas you will encounter this change in are: MessageOptions#content, the properties of a MessageEmbed, and passing objects such as users or roles, expecting them to be stringified. - message.channel.send(user); + message.channel.send(user.toString()); let count = 5; - embed.addField('Count', count); + embed.addField('Count', count.toString()); 123456# IntentsAs v13 makes the switch to Discord API v9, it is now required to specify all intents your bot uses in the Client constructor. The intents option has also moved from ClientOptions#ws#intents to ClientOptions#intents. The shortcuts Intents.ALL, Intents.NON_PRIVILEGED, and Intents.PRIVILEGED have all been removed to discourage bad practices of enabling unused intents. Refer to our more detailed article about this topic. - const client = new Client({ ws: { intents: [Intents.FLAGS.GUILDS] } }); + const client = new Client({ intents: [Intents.FLAGS.GUILDS] }); 12# Structures#extendThe concept of extendable Structures has been completely removed from discord.js. For more information on why this decision was made, refer to this pull requestopen in new window. There is no swap-in replacement for this, as the intention is to change the code design rather than enable something equally bad. For some real-world example of the alternatives provided in the PR, you may have been extending the Guild class with guild-specific settings: Structures.extend('Guild', Guild => { return class MyGuild extends Guild { constructor(client, data) { super(client, data); this.settings = { prefix: '!', }; } }; }); 12345678910This functionality can be replicated using the WeakMap or Collection example, even attaching it to the Client if necessary: client.guildSettings = new Collection(); client.guildSettings.set(guildId, { prefix: '!' }); // In practice, you would populate this Collection with data fetched from a database const { prefix } = message.client.guildSettings.get(message.guild.id); 12345# CollectorsAll Collector related classes and methods (both .create*() and .await*()) now take a single object parameter which also includes the filter. - const collector = message.createReactionCollector(collectorFilter, { time: 15_000 }); + const collector = message.createReactionCollector({ filter: collectorFilter, time: 15_000 }); - const reactions = await message.awaitReactions(collectorFilter, { time: 15_000 }); + const reactions = await message.awaitReactions({ filter: collectorFilter, time: 15_000 }); 12345# Naming conventionsSome commonly used naming conventions in discord.js have changed. # Thing#thingIdThe casing of thingID properties has changed to thingId. This is a more-correct casing for the camelCase used by discord.js as Id is an abbreviation of Identifier, not an acronym. This includes: afkChannelId, applicationId, channelId, creatorId, guildId, lastMessageId, ownerId, parentId, partyId, processId, publicUpdatesChannelId, resolveId, rulesChannelId, sessionId, shardId, systemChannelId, webhookId, widgetChannelId, and workerId. - console.log(guild.ownerID); + console.log(guild.ownerId); - console.log(interaction.channelID); + console.log(interaction.channelId); 12345# Client#messageThe message event has been renamed to messageCreate, to bring the library in line with Discord's naming conventions. Using message will still work, but you'll receive a deprecation warning until you switch over. - client.on("message", message => { ... }); + client.on("messageCreate", message => { ... }); 12# Allowed MentionsclientOptions.disableMentions has been removed and replaced with clientOptions.allowedMentions! The Discord API now allows bots much more granular control over mention parsing, down to the specific id. Refer to the Discord API documentationopen in new window for more information. - const client = new Discord.Client({ disableMentions: 'everyone' }); + const client = new Discord.Client({ allowedMentions: { parse: ['users', 'roles'], repliedUser: true } }); 12# Replies / Message#replyMessage#reply will no longer result in the bot prepending a user mention to the content, replacing the behavior with Discord's reply feature. MessageOptions#reply no longer takes a user id. It has been replaced with a ReplyOptions type, expecting MessageOptions#reply#messageReference as a Message id. - channel.send('content', { reply: '123456789012345678' }); // User id + channel.send({ content: 'content', reply: { messageReference: '765432109876543219' }}); // Message id 12The new MessageOptions.allowedMentions.repliedUser boolean option determines if the reply will notify the author of the original message. - message.reply('content') + message.reply({ content: 'content', allowedMentions: { repliedUser: false }}) 12Note that this will disable all other mentions in this message. To enable other mentions, you will need to include other allowedMentions fields. See the above "Allowed Mentions" section for more. # Bitfields / PermissionsBitfields are now BigInts instead of Numbers. This can be handled using the BigInt() class, or the n-suffixed BigInt literalopen in new window. - const p = new Permissions(104_324_673); + const p = new Permissions(BigInt(104_324_673)); + const p = new Permissions(104_324_673n); 123In addition, the usage of string literals for bitfield flags such as Permissions and UserFlags is discouraged; you should use the flag instead. - permissions.has('SEND_MESSAGES') + permissions.has(Permissions.FLAGS.SEND_MESSAGES) 12# DM ChannelsOn Discord API v8 and later, DM Channels do not emit the CHANNEL_CREATE event, which means discord.js is unable to cache them automatically. In order for your bot to receive DMs, the CHANNEL partial must be enabled. # WebpackWebpack builds are no longer supported. # Changes and deletions# ActivityTypeThe CUSTOM_STATUS type has been renamed to CUSTOM. # APIMessageThe APIMessage class has been renamed to MessagePayload, resolving a naming clash with an interface in the discord-api-types library which represents raw message data objects. # Channel# Channel#typeChannel types are now uppercase and align with Discord's naming conventions. - if(channel.type === 'text') channel.send('Content'); + if(channel.type === 'GUILD_TEXT') channel.send('Content'); 12# Client# Client#emojisThe Client Emoji manager is now a BaseGuildEmojiManager, providing cache resolution only and removing methods that would fail to create emojis as there was no Guild context. # Client#fetchApplicationThe Client#fetchApplication method has been removed and replaced with the Client#application property. - client.fetchApplication().then(application => console.log(application.name)) + console.log(client.application.name); 12# Client#fetchWidgetThis method has been renamed to fetchGuildWidget to better represent its functionality. # Client#generateInviteClient#generateInvite no longer supports PermissionsResolvable as its argument, requiring InviteGenerationOptions instead. This also requires that at least one of either bot or applications.commands is provided in scopes to generate a valid invite URL. To generate an invite link with slash commands permissions: client.generateInvite({ scopes: ['applications.commands'] }); 1To generate an invite link for a bot and define required permissions: - client.generateInvite([Permissions.FLAGS.SEND_MESSAGES]); + client.generateInvite({ scopes: ['bot'], permissions: [Permissions.FLAGS.SEND_MESSAGES] }) 12# Client#loginPreviously when a token had reached its 1000 login limit for the day, discord.js would treat this as a rate limit and silently wait to login again, but this was not communicated to the user. This will now instead cause an error to be thrown. # Client#typingStartThe Client#typingStart event now only emits a Typing structure. Previously, Channel and User were emitted. # Client#setInterval# Client#setTimeoutThe Client timeout methods have all been removed. These methods existed for the purpose of caching timeouts internally so they could be cleared when the Client is destroyed. Since timers now have an unref method in Node, this is no longer required. # ClientOptions# ClientOptions#fetchAllMembersThe ClientOptions#fetchAllMembers option has been removed. With the introduction of gateway intents, the fetchAllMembers Client option would often fail and causes significant delays in ready states or even cause timeout errors. As its purpose is contradictory to Discord's intentions to reduce scraping of user and presence data, it has been removed. # ClientOptions#messageCacheMaxSizeThe ClientOptions#messageCacheMaxSize option has been removed. Instead, use ClientOptions#makeCache to customize the MessageManager cache. # ClientOptions#messageEditHistoryMaxSizeThe ClientOptions#messageEditHistoryMaxSize option has been removed. To reduce caching, discord.js will no longer store an edit history. You will need to implement this yourself if required. # ClientUser# ClientUser#setActivityThe ClientUser#setActivity method no longer returns a Promise. # ClientUser#setAFKThe ClientUser#setAFK method no longer returns a Promise. # ClientUser#setPresenceThe ClientUser#setPresence method no longer returns a Promise. PresenceData#activity was replaced with PresenceData#activities, which now requires an Array. - client.user.setPresence({ activity: { name: 'with discord.js' } }); + client.user.setPresence({ activities: [{ name: 'with discord.js' }] }); 12# ClientUser#setStatusThe ClientUser#setStatus method no longer returns a Promise. # Collection# Collection#array()# Collection#keyArray()These methods existed to provide access to a cached array of Collection values and keys respectively, which other Collection methods relied on internally. Those other methods have been refactored to no longer rely on cache, so those arrays and these methods have been removed. You should instead construct an array by spreading the iterators returned by the base Map class methods: - collection.array(); + [...collection.values()]; - collection.keyArray(); + [...collection.keys()]; 12345# ColorResolvableColors have been updated to align with the new Discord branding. # Guild# Guild#addMemberThis method has been removed, with functionality replaced by the new GuildMemberManager#add. - guild.addMember(user, { accessToken: token }); + guild.members.add(user, { accessToken: token }); 12# Guild#fetchBan# Guild#fetchBansThese methods have been removed, with functionality replaced by the new GuildBanManager. - guild.fetchBan(user); + guild.bans.fetch(user); - guild.fetchBans(); + guild.bans.fetch(); 12345# Guild#fetchInvitesThis method has been removed, with functionality replaced by the new GuildInviteManager. - guild.fetchInvites(); + guild.invites.fetch(); 12# Guild#fetchVanityCodeThe Guild#fetchVanityCode method has been removed. - Guild.fetchVanityCode().then(code => console.log(`Vanity URL: https://discord.gg/${code}`)); + Guild.fetchVanityData().then(res => console.log(`Vanity URL: https://discord.gg/${res.code} with ${res.uses} uses`)); 12# Guild#fetchWidgetThe Guild#fetchWidget() method now retrieves the widget data for the guild instead of the widget settings. See Client#fetchGuildWidget(). The original functionality has moved to the new method Guild#fetchWidgetSettings(). # Guild#memberThe Guild#member() helper/shortcut method has been removed. - guild.member(user); + guild.members.cache.get(user.id) 12# Guild#mfaLevelThe Guild#mfaLevel property is now an enum. # Guild#nsfwThe Guild#nsfw property has been removed, replaced by Guild#nsfwLevel. # Guild#ownerThe Guild#owner property has been removed as it was unreliable due to caching, replaced with Guild#fetchOwner. - console.log(guild.owner); + guild.fetchOwner().then(console.log); 12# Guild#setWidgetThe Guild#setWidget() method has been renamed to Guild#setWidgetSettings(). # Guild#voiceThe Guild#voice getter has been removed. - guild.voice + guild.me.voice 12# GuildChannel# GuildChannel#createOverwriteThis method has been removed, with functionality replaced by the new PermissionOverwriteManager. - channel.createOverwrite(user, { VIEW_CHANNEL: false }); + channel.permissionOverwrites.create(user, { VIEW_CHANNEL: false }); 12# GuildChannel#createInvite# GuildChannel#fetchInvitesThese methods have been removed from GuildChannel and placed only on subclasses for which invites can be created. These are TextChannel, NewsChannel, VoiceChannel, StageChannel, and StoreChannel. On these subclasses, the method now supports additional options: targetUser to target the invite to join a particular streaming usertargetApplication to target the invite to a particular Discord activitytargetType defines the type of the target for this invite; user or application# GuildChannel#overwritePermissionsThis method has been removed, with functionality replaced by the new PermissionOverwriteManager. - channel.overwritePermissions([{ id: user.id , allow: ['VIEW_CHANNEL'], deny: ['SEND_MESSAGES'] }]); + channel.permissionOverwrites.set([{ id: user.id , allow: ['VIEW_CHANNEL'], deny: ['SEND_MESSAGES'] }]); 12# GuildChannel#permissionOverwritesThis method no longer returns a Collection of PermissionOverwrites, instead providing access to the PermissionOverwriteManager. # GuildChannel#setTopicThe GuildChannel#setTopic method has been removed and placed only on subclasses for which topics can be set. These are TextChannel, NewsChannel, and StageChannel. # GuildChannel#updateOverwriteThis method has been removed, with functionality replaced by the new PermissionOverwriteManager. - channel.updateOverwrite(user, { VIEW_CHANNEL: false }); + channel.permissionOverwrites.edit(user, { VIEW_CHANNEL: false }); 12# GuildMember# GuildMember#banGuildMember#ban() will throw a TypeError when a string is provided instead of an options object. - member.ban('reason') + member.ban({ reason: 'reason' }) 12# GuildMember#hasPermissionThe GuildMember#hasPermission shortcut/helper method has been removed. - member.hasPermission(Permissions.FLAGS.SEND_MESSAGES); + member.permissions.has(Permissions.FLAGS.SEND_MESSAGES); 12# GuildMember#lastMessage# GuildMember#lastMessageId# GuildMember#lastMessageChannelIdNone of these properties were actually provided by Discord, instead relying on potentially inaccurate client cache, and have been removed. # GuildMember#presenceThe GuildMember#presence property can now be null, rather than a generic offline presence, such as when the GUILD_PRESENCES intent is not enabled. # GuildMemberManager# GuildMemberManager#banThe GuildMemberManager#ban method will throw a TypeError when a string is provided instead of an options object. - guild.members.ban('123456789012345678', 'reason') + guild.members.ban('123456789012345678', { reason: 'reason' }) 12# Message / MessageManager# Message#deleteThe Message.delete() method no longer accepts any options, requiring a timed-delete to be performed manually. - message.delete({ timeout: 10_000 }); + setTimeout(() => message.delete(), 10_000); 12reason is no longer a parameter as it is not used by the API. # MessageManager#deleteThe MessageManager.delete() method no longer accepts any additional options, requiring a timed-delete to be performed manually. - channel.messages.delete('123456789012345678', { timeout: 10_000 }); + setTimeout(() => channel.messages.delete('123456789012345678'), 10_000); 12reason is no longer a parameter as it is not used by the API. # Message#editsThe Message#edits property has been removed. # MessageEmbed# MessageEmbed#attachFilesThe MessageEmbed#attachFiles method has been removed. Instead, files should be attached to the Message directly via MessageOptions. - channel.send({ embeds: [new MessageEmbed().setTitle("Files").attachFiles(file)] }) + channel.send({ embeds: [new MessageEmbed().setTitle("Files")], files: [file] }) 12# Permissions# Permissions#FLAGS.MANAGE_EMOJISPermissions.FLAGS.MANAGE_EMOJIS is now Permissions.FLAGS.MANAGE_EMOJIS_AND_STICKERS. # ReactionUserManager# ReactionUserManager#fetchThe before option has been removed as it was not supported by the API. # RoleManager# RoleManager#createThe options passed to RoleManager#create no longer need to be nested in a data object. Additionally, reason is now part of the options, not a second parameter. - guild.roles.create({ data: { name: "New role" } }, "Creating new role"); + guild.roles.create({ name: "New role", reason: "Creating new role" }) 12# RoleManager#fetchThe RoleManager#fetch() method will now return a Collection instead of a RoleManager when called without params. # Shard# Shard#respawnThe options for the Shard#respawn method are now an object instead of separate params. In addition, the spawnTimeout param has been renamed to timeout. This means the user no longer needs to pass defaults to fill each positional param. - shard.respawn(500, 30_000); + shard.respawn({ delay: 500, timeout: 30_000 }); 12# Shard#spawnThe spawnTimeout param has been renamed to timeout. # ShardClientUtil# ShardClientUtil#broadcastEvalThe ShardClientUtil#broadcastEval method no longer accepts a string, instead expecting a function. - client.shard.broadcastEval('this.guilds.cache.size') + client.shard.broadcastEval(client => client.guilds.cache.size) .then(results => console.log(`${results.reduce((prev, val) => prev + val, 0)} total guilds`)) .catch(console.error); 1234# ShardClientUtil#respawnAllThe options for the ShardClientUtil#respawnAll method are now an object instead of separate params. In addition, the spawnTimeout param has been renamed to timeout. This means the user no longer needs to pass defaults to fill each positional param. - client.shard.respawnAll(5_000, 500, 30_000); + client.shard.respawnAll({ shardDelay: 5_000, respawnDelay: 500, timeout: 30_000 }); 12# ShardingManager# ShardingManager#broadcastEvalThe ShardingManager#broadcastEval method no longer accepts a string, instead expecting a function. See ShardClientUtil#broadcastEval. # ShardingManager#spawnThe options for the ShardingManager#spawn method are now an object instead of separate params. In addition, the spawnTimeout param has been renamed to timeout. This means the user no longer needs to pass defaults to fill each positional param. - manager.spawn('auto', 5_500, 30_000); + manager.spawn({ amount: 'auto', delay: 5_500, timeout: 30_000 }); 12# ShardingManager#respawnAllThe options for the ShardingManager#respawnAll method are now an object instead of separate params. In addition, the spawnTimeout param has been renamed to timeout. This means the user no longer needs to pass defaults to fill each positional param. - manager.respawnAll(5_000, 500, 30_000); + manager.respawnAll({ shardDelay: 5_000, respawnDelay: 500, timeout: 30_000 }); 12# TextChannel# TextChannel#startTyping# TextChannel#stopTypingThese methods have both been replaced by a singular TextChannel.sendTyping(). This method automatically stops typing after 10 seconds, or when a message is sent. # User# User#lastMessage# User#lastMessageIdNeither of these properties were actually provided by Discord, instead relying on potentially inaccurate client cache, and have been removed. # User#localeThe User.locale property has been removed, as this property is not exposed to bots. # User#presenceThe User.presence property has been removed. Presences are now only found on GuildMember. # User#typingInAs discord.js no longer caches typing event data, the User.typingIn() method has been removed. # User#typingSinceInAs discord.js no longer caches typing event data, the User.typingSinceIn() method has been removed. # User#typingDurationInAs discord.js no longer caches typing event data, the User.typingDurationIn() method has been removed. # UserFlagsThe deprecated UserFlags DISCORD_PARTNER and VERIFIED_DEVELOPER / EARLY_VERIFIED_DEVELOPER have been removed in favor of their renamed versions. - user.flags.has(UserFlags.FLAGS.DISCORD_PARTNER) + user.flags.has(UserFlags.FLAGS.PARTNERED_SERVER_OWNER) - user.flags.has(UserFlags.FLAGS.VERIFIED_DEVELOPER) + user.flags.has(UserFlags.FLAGS.EARLY_VERIFIED_BOT_DEVELOPER) 12345The new flag DISCORD_CERTIFIED_MODERATOR has been added. # UtilShortcuts to Util methods which were previously exported at the top level have been removed. # Util#convertToBuffer# Util#str2abBoth were removed in favor of Node's built-in Buffer methods. # Util#fetchRecommendedShardsThe Util#fetchRecommendedShards() method now supports an additional option multipleOf to calculate the number to round up to, e.g. a multiple of 16 for large bot sharding. # Util#resolveStringThe Util#resolveString method has been removed. discord.js now enforces that users provide strings where expected rather than resolving one on their behalf. # VoiceState# VoiceState#kickThe VoiceState#kick method has been renamed to VoiceState#disconnect. # WebhookClientThe WebhookClient constructor no longer accepts id, token as the first two parameters, instead taking a data object. This object supports an additional option url, allowing creation of a WebhookClient from a webhook URL. - new WebhookClient(id, token, options); + new WebhookClient({ id, token }, options); + new WebhookClient({ url }, options); 1234# Additions# ActivityTypesA new activity type COMPETING has been added. # ApplicationCommandProvides API support for slash commands. # ApplicationCommandManagerProvides API support for creating, editing and deleting slash commands. # ApplicationCommandPermissionsManagerProvides API support for creating, editing, and deleting permission overwrites on slash commands. # ApplicationFlagsProvides an enumerated bitfield for ClientApplication flags. # BaseGuildThe new BaseGuild class is extended by both Guild and OAuth2Guild. # BaseGuildTextChannelThe new BaseGuildTextChannel class is extended by both TextChannel and NewsChannel. # BaseGuildVoiceChannelThe new BaseGuildVoiceChannel class is extended by both VoiceChannel and StageChannel. # ButtonInteractionProvides gateway support for a MessageComponentInteraction coming from a button component. # Channel# Channel#isText()Checks and typeguards if a channel is Text-Based; one of TextChannel, DMChannel, NewsChannel or ThreadChannel. # Channel#isThread()Checks and typeguards if a channel is a ThreadChannel. # Channel#isVoice()Checks and typeguards if a channel is Voice-Based; VoiceChannel or StageChannel. # Client# Client#applicationCommandCreateEmitted when a guild application command is created. # Client#applicationCommandDeleteEmitted when a guild application command is deleted. # Client#applicationCommandUpdateEmitted when a guild application command is updated. # Client#interactionCreateEmitted when an interaction is created. # Client#stageInstanceCreateEmitted when a stage instance is created. # Client#stageInstanceDeleteEmitted when a stage instance is deleted. # Client#stageInstanceUpdateEmitted when a stage instance gets updated, e.g. change in topic or privacy level. # Client#stickerCreateEmitted when a custom sticker is created in a guild. # Client#stickerDeleteEmitted when a custom sticker is deleted in a guild. # Client#stickerUpdateEmitted when a custom sticker is updated in a guild. # Client#threadCreateEmitted when a thread is created or when the client user is added to a thread. # Client#threadDeleteEmitted when a thread is deleted. # Client#threadListSyncEmitted when the client user gains access to a text or news channel that contains threads. # Client#threadMembersUpdateEmitted when members are added or removed from a thread. Requires the GUILD_MEMBERS privileged intent. # Client#threadMemberUpdateEmitted when the client user's thread member is updated. # Client#threadUpdateEmitted when a thread is updated, e.g. name change, archive state change, locked state change. # ClientOptions# ClientOptions#failIfNotExistsThis parameter sets the default behavior for ReplyMessageOptions#failIfNotExists, allowing or preventing an error when replying to an unknown Message. # CollectorOptions# CollectorOptions#filterThis parameter is now optional and will fall back to a function that always returns true if not provided. # CommandInteractionProvides gateway support for slash command interactions. For more information refer to the slash commands section of the guide. # Guild# Guild#bansProvides access to the Guild's GuildBanManager. # Guild#createGuild#systemChannelFlags can now be set in the Guild#create method. # Guild#editThe Guild#description and Guild#features properties can now be edited. # Guild#editWelcomeScreenProvides API support for bots to edit the Guild's WelcomeScreen. # Guild#emojisThe GuildEmojiManager class now extends BaseGuildEmojiManager. In addition to the existing methods, it now supports GuildEmojiManager#fetch. # Guild#fetchWelcomeScreenProvides API support for fetching the Guild's WelcomeScreen. # Guild#fetchWidgetProvides API support for the Guild's Widget, containing information about the guild and its members. # Guild#invitesProvides access to the new GuildInviteManager. # Guild#nsfwLevelThe Guild#nsfwLevel property is now represented by the NSFWLevel enum. # Guild#premiumTierThe Guild#premiumTier property is now represented by the PremiumTier enum. # Guild#setChannelPositionsNow supports setting the parent of multiple channels, and locking their permissions via the ChannelPosition#parent and ChannelPosition#lockPermissions options. # GuildBanManagerProvides improved API support for handling and caching bans. Starting from 13.11, developers should utilise deleteMessageSeconds instead of days: .create('123456789', { - days: 3 + deleteMessageSeconds: 3 * 24 * 60 * 60 }); 1234days is deprecated and will be removed in the future. # GuildChannel# GuildChannel#cloneNow supports setting the position property. # GuildChannelManager# GuildChannelManager#fetchNow supports fetching the channels of a Guild. # GuildChannelManager#fetchActiveThreadsRetrieves a list of the active threads in a Guild. # GuildInviteManagerAligns support for creating and fetching invites with the managers design. This replaces Guild#fetchInvites. # GuildManager# GuildManager#createNow supports specifying the AFK and system channels when creating a new guild. # GuildManager#fetchNow supports fetching multiple guilds, returning a Promise if used in this way. # GuildEmojiManager# GuildEmojiManager#fetchProvides API support for the GET /guilds/{guild.id}/emojis endpoint. # GuildMember# GuildMember#pendingFlags whether a member has passed the guild's membership gate. The flag is true before accepting and fires guildMemberUpdate when the member accepts. # GuildMemberManagerSeveral methods were added to GuildMemberManager to provide API support for uncached members. # GuildMemberManager#editguild.members.edit('123456789012345678', data, reason) is equivalent to GuildMember#edit(data, reason). # GuildMemberManager#kickguild.members.kick('123456789012345678', reason) is equivalent to GuildMember#kick(reason). # GuildMemberManager#searchProvides API support for querying GuildMembers via the REST API endpoint. GuildMemberManager#fetch uses the websocket gateway to receive data. # GuildMemberRoleManager# GuildMemberRoleManager#botRoleGets the managed role this member created when joining the guild if any. # GuildMemberRoleManager#premiumSubscriberRoleGets the premium subscriber (booster) role if present on the member. # GuildPreview# GuildPreview#createdAt# GuildPreview#createdTimestampThe datetime at which the GuildPreview was created. # GuildTemplateProvides API support for server templatesopen in new window. # Integration# Integration#rolesA Collection of Roles which are managed by the integration. # InteractionProvides gateway support for slash command and message component interactions. For more information refer to the slash commands and message components sections of the guide. # InteractionCollectorProvides a way for users to collect any type of Interaction. This class has a more flexible design than other Collectors, able to be bound to any Guild, Channel, or Message as appropriate. TypeScript developers can also leverage generics to define the subclass of Interaction that will be returned. # InteractionWebhookProvides webhook support specifically for interactions, due to their unique qualities. # InviteGuildProvides API support for the partial Guild data available from an Invite. # InviteStageInstanceProvides API support for bots to inviting users to stage instances. # Message# Message#awaitMessageComponentA shortcut method to create a promisified InteractionCollector which resolves to a single MessageComponentInteraction. # Message#createMessageComponentCollectorA shortcut method to create an InteractionCollector for components on a specific message. # Message#crosspostableChecks permissions to see if a Message can be crossposted. # Message#editEditing and/or removing attachments when editing a Message is now supported. # Message#fetchReferenceProvides support for fetching the Message referenced by Message#reference, if the client has access to do so. # Message#reactNow supports both and as valid inputs. # Message#removeAttachmentsRemoves the attachments from a message. Requires MANAGE_MESSAGES to remove attachments from messages authored by other users. # Message#startThreadStarts a ThreadChannel using this message as the starter message. # Message#stickersA Collection of Stickers in the message. # MessageActionRowA builder class which makes constructing action row type message components easier. # MessageAttachment# MessageAttachment#contentTypeThe media type of a MessageAttachment. # MessageButtonA builder class which makes constructing button type message components easier. # MessageComponentInteractionProvides gateway support for receiving interactions from message components. Subclass of Interaction. # MessageEmbed# MessageEmbed#setFieldsReplaces all fields in the embed with the new array of fields provided. embed.setFields(newFields) is equivalent to embed.spliceFields(0, embed.fields.length, newFields). # MessageManagerMethods were added to MessageManager to provide API support for uncached messages. # MessageManager#crosspostchannel.messages.crosspost('876543210987654321') is equivalent to message.crosspost(). # MessageManager#editchannel.messages.edit('876543210987654321', content, options) is equivalent to message.edit(content, options). # MessageManager#pinchannel.messages.pin('876543210987654321', options) is approximately equivalent to message.pin(options) but does not resolve to a Message. # MessageManager#reactchannel.messages.react('876543210987654321', emoji) is approximately equivalent to message.react(emoji) but does not resolve to a MessageReaction. # MessageManager#unpinchannel.messages.unpin('876543210987654321', options) is approximately equivalent to message.unpin(options) but does not resolve to a Message. # MessageMentions# MessageMentions#repliedUserChecks if the author of a message being replied to has been mentioned. # MessagePayloadThis class has been renamed from APIMessage. Global headers can now be set in the HTTP options. # MessageSelectMenuA builder class which makes constructing select menu type message components easier. # NewsChannel# NewsChannel#addFollowerProvides API support for bots to follow announcements in other channels. # NewsChannel#setTypeAllows conversion between NewsChannel and TextChannel. # Permissions# Permissions#STAGE_MODERATORStatic bitfield representing the permissions required to moderate a stage channel. # PermissionOverwriteManagerReplaces the createOverwrite, updateOverwrite, and overwritePermissions methods of GuildChannel, aligning the design with other Managers. # Role# Role#tagsTags for roles belonging to bots, integrations, or premium subscribers. # RoleManager# RoleManager#botRoleForGets the managed role a bot created when joining the guild, if any. # RoleManager#editguild.roles.edit('123456789098765432', options) is equivalent to role.edit(options). # RoleManager#premiumSubscriberRoleGets the premium subscriber (booster) role for the Guild, if any. # SelectMenuInteractionProvides gateway support for a MessageComponentInteraction coming from a select menu component. # StageChannelProvides API support for stage channels. # StageInstanceProvides API support for stage instances. Stage instances contain information about live stages. # StageInstanceManagerProvides API support for the bot to create, edit, and delete live stage instances, and stores a cache of stage instances. # StickerProvides API support for Discord Stickers. # StickerPackProvides API support for Discord Sticker packs. # TextChannel# TextChannel#awaitMessageComponentA shortcut method to create a promisified InteractionCollector which resolves to a single MessageComponentInteraction. # TextChannel#createMessageComponentCollectorA shortcut method to create an InteractionCollector for components on a specific channel. # TextChannel#setTypeAllows conversion between TextChannel and NewsChannel. # TextChannel#threadsProvides access to the ThreadManager for this channel. # ThreadChannelProvides API support for thread channels. # ThreadChannelManagerProvides API support for the bot to create, edit, and delete threads, and stores a cache of ThreadChannels. # ThreadMemberRepresent a member of a thread and their thread-specific metadata. # ThreadMemberManagerProvides API support for the bot to add and remove members from threads, and stores a cache of ThreadMembers. # TypingRepresents a typing state for a user in a channel. # Webhook# Webhook#deleteMessageWebhooks can now delete messages that were sent by the Webhook. # Webhook#editMessageWebhooks can now edit messages that were sent by the Webhook. # Webhook#fetchMessageWebhooks can now fetch messages that were sent by the Webhook. # Webhook#sourceChannel# Webhook#sourceGuildWebhooks can now have a sourceGuild and sourceChannel if the message is being crossposted. # WelcomeChannelRepresents the channels that can be seen in a Guild's WelcomeScreen. # WelcomeScreenProvides API support for a Guild's welcome screen. # WidgetRepresents a Guild's widget. # WidgetMemberPartial information about a guild's members stored in a widget. # Util# FormattersA number of new formatter functions are provided in the Util class, to easily handle adding markdown to strings. # Util#resolvePartialEmojiA helper method that attempts to resolve properties for a raw emoji object from input data, without the use of the discord.js Client class or its EmojiManager. # Util#verifyStringA helper method which is used to internally validate string arguments provided to methods in discord.js. Edit this page open in new windowLast Updated: 12/29/2023, 6:28:37 PM |
CopyRight 2018-2019 实验室设备网 版权所有 |